import click
from flask import Flask
from flask.cli import AppGroup
from flask import Blueprint

app = Flask(__name__)


@app.cli.command()
def cli_say_hello():
    click.echo("Say Hello")


@app.cli.command("create-user")
@click.argument("name")
def cli_create_user(name):
    """
    命令参数
    :param name:
    :return:
    """
    click.echo("Create User")
    click.echo(name)


user_cli = AppGroup('user')


@user_cli.command('add')
@click.argument("name")
def cli_add_user(name):
    """
    用户组 添加用户
    :param name:
    :return:
    """
    click.echo("Add User")
    click.echo(name)


@user_cli.command('del')
@click.argument("name")
def cli_del_user(name):
    """
    用户组 删除用户
    :param name:
    :return:
    """
    click.echo("Del User")
    click.echo(name)


app.cli.add_command(user_cli)

bp = Blueprint('teachers', __name__)


@bp.cli.command('add')
@click.argument('name')
def create(name):
    """
    教师组 添加教师
    :param name:
    :return:
    """
    click.echo("Add Teacher")
    click.echo(name)


app.register_blueprint(bp)


@app.route('/')
def hello_world():
    return 'Hello World!'


if __name__ == '__main__':
    app.run()
